g_autofree char *msg = g_strdup_printf ("Server returned HTTP %lu", response);
g_task_return_new_error (task, G_IO_ERROR, giocode,
"%s", msg);
- if (req->fetcher->remote_name)
+ if (req->fetcher->remote_name &&
+ !((req->flags & OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT) > 0 &&
+ giocode == G_IO_ERROR_NOT_FOUND))
_ostree_fetcher_journal_failure (req->fetcher->remote_name,
eff_url, msg);
_ostree_fetcher_request_to_tmpfile (OstreeFetcher *self,
GPtrArray *mirrorlist,
const char *filename,
+ OstreeFetcherRequestFlags flags,
guint64 max_size,
int priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- _ostree_fetcher_request_async (self, mirrorlist, filename, 0, FALSE,
+ _ostree_fetcher_request_async (self, mirrorlist, filename, flags, FALSE,
max_size, priority, cancellable,
callback, user_data);
}
g_prefix_error (&local_error,
"All %u mirrors failed. Last error was: ",
pending->mirrorlist->len);
- if (pending->thread_closure->remote_name)
+ if (pending->thread_closure->remote_name &&
+ !((pending->flags & OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT) > 0 &&
+ code == G_IO_ERROR_NOT_FOUND))
_ostree_fetcher_journal_failure (pending->thread_closure->remote_name,
uristring, local_error->message);
_ostree_fetcher_request_to_tmpfile (OstreeFetcher *self,
GPtrArray *mirrorlist,
const char *filename,
+ OstreeFetcherRequestFlags flags,
guint64 max_size,
int priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- _ostree_fetcher_request_async (self, mirrorlist, filename, 0, FALSE,
+ _ostree_fetcher_request_async (self, mirrorlist, filename, flags, FALSE,
max_size, priority, cancellable,
callback, user_data);
}
_ostree_fetcher_mirrored_request_to_membuf (OstreeFetcher *fetcher,
GPtrArray *mirrorlist,
const char *filename,
- gboolean add_nul,
- gboolean allow_noent,
+ OstreeFetcherRequestFlags flags,
GBytes **out_contents,
guint64 max_size,
GCancellable *cancellable,
data.error = error;
_ostree_fetcher_request_to_membuf (fetcher, mirrorlist, filename,
- add_nul ? OSTREE_FETCHER_REQUEST_NUL_TERMINATION : 0,
+ flags,
max_size, OSTREE_FETCHER_DEFAULT_PRIORITY,
cancellable, fetch_uri_sync_on_complete, &data);
while (!data.done)
if (!data.result_buf)
{
- if (allow_noent)
+ if (flags & OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT)
{
if (g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
gboolean
_ostree_fetcher_request_uri_to_membuf (OstreeFetcher *fetcher,
OstreeFetcherURI *uri,
- gboolean add_nul,
- gboolean allow_noent,
+ OstreeFetcherRequestFlags flags,
GBytes **out_contents,
guint64 max_size,
GCancellable *cancellable,
{
g_autoptr(GPtrArray) mirrorlist = g_ptr_array_new ();
g_ptr_array_add (mirrorlist, uri); /* no transfer */
- return _ostree_fetcher_mirrored_request_to_membuf (fetcher, mirrorlist, NULL,
- add_nul, allow_noent,
+ return _ostree_fetcher_mirrored_request_to_membuf (fetcher, mirrorlist, NULL, flags,
out_contents, max_size,
cancellable, error);
}
gboolean _ostree_fetcher_mirrored_request_to_membuf (OstreeFetcher *fetcher,
GPtrArray *mirrorlist,
const char *filename,
- gboolean add_nul,
- gboolean allow_noent,
+ OstreeFetcherRequestFlags flags,
GBytes **out_contents,
guint64 max_size,
GCancellable *cancellable,
gboolean _ostree_fetcher_request_uri_to_membuf (OstreeFetcher *fetcher,
OstreeFetcherURI *uri,
- gboolean add_nul,
- gboolean allow_noent,
+ OstreeFetcherRequestFlags flags,
GBytes **out_contents,
guint64 max_size,
GCancellable *cancellable,
OSTREE_FETCHER_FLAGS_TRANSFER_GZIP = (1 << 1)
} OstreeFetcherConfigFlags;
+typedef enum {
+ OSTREE_FETCHER_REQUEST_NUL_TERMINATION = (1 << 0),
+ OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT = (1 << 1)
+} OstreeFetcherRequestFlags;
+
void
_ostree_fetcher_uri_free (OstreeFetcherURI *uri);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(OstreeFetcherURI, _ostree_fetcher_uri_free)
void _ostree_fetcher_request_to_tmpfile (OstreeFetcher *self,
GPtrArray *mirrorlist,
const char *filename,
+ OstreeFetcherRequestFlags flags,
guint64 max_size,
int priority,
GCancellable *cancellable,
char **out_filename,
GError **error);
-typedef enum {
- OSTREE_FETCHER_REQUEST_NUL_TERMINATION = (1 << 0)
-} OstreeFetcherRequestFlags;
-
void _ostree_fetcher_request_to_membuf (OstreeFetcher *self,
GPtrArray *mirrorlist,
const char *filename,
gssize n_bytes;
if (!_ostree_fetcher_request_uri_to_membuf (self->metalink->fetcher,
- uri,
- FALSE,
- FALSE,
- &bytes,
+ uri, 0, &bytes,
self->metalink->max_size,
self->cancellable,
error))
request.urls = g_ptr_array_new_with_free_func ((GDestroyNotify) _ostree_fetcher_uri_free);
request.parser = g_markup_parse_context_new (&metalink_parser, G_MARKUP_PREFIX_ERROR_POSITION, &request, NULL);
- if (!_ostree_fetcher_request_uri_to_membuf (self->fetcher,
- self->uri,
- FALSE,
- FALSE,
- &contents,
- self->max_size,
- cancellable,
- error))
+ if (!_ostree_fetcher_request_uri_to_membuf (self->fetcher, self->uri, 0,
+ &contents, self->max_size,
+ cancellable, error))
goto out;
data = g_bytes_get_data (contents, &len);
{
g_autoptr(GBytes) bytes = NULL;
if (!_ostree_fetcher_mirrored_request_to_membuf (fetcher, mirrorlist,
- filename, TRUE, FALSE,
+ filename, OSTREE_FETCHER_REQUEST_NUL_TERMINATION,
&bytes,
OSTREE_MAX_METADATA_SIZE,
cancellable, error))
else
pull_data->n_outstanding_content_fetches++;
+ OstreeFetcherRequestFlags flags = 0;
/* Override the path if we're trying to fetch the .commitmeta file first */
if (fetch->is_detached_meta)
{
_ostree_loose_path (buf, expected_checksum, OSTREE_OBJECT_TYPE_COMMIT_META, pull_data->remote_mode);
obj_subpath = g_build_filename ("objects", buf, NULL);
mirrorlist = pull_data->meta_mirrorlist;
+ flags |= OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT;
}
else
{
expected_max_size = 0;
_ostree_fetcher_request_to_tmpfile (pull_data->fetcher, mirrorlist,
- obj_subpath, expected_max_size,
+ obj_subpath, flags, expected_max_size,
is_meta ? OSTREE_REPO_PULL_METADATA_PRIORITY
: OSTREE_REPO_PULL_CONTENT_PRIORITY,
pull_data->cancellable,
g_assert_cmpint (pull_data->n_outstanding_deltapart_fetches, <=, _OSTREE_MAX_OUTSTANDING_DELTAPART_REQUESTS);
_ostree_fetcher_request_to_tmpfile (pull_data->fetcher,
pull_data->content_mirrorlist,
- deltapart_path, fetch->size,
+ deltapart_path, 0, fetch->size,
OSTREE_FETCHER_DEFAULT_PRIORITY,
pull_data->cancellable,
static_deltapart_fetch_on_complete,
else
{
ret = _ostree_fetcher_mirrored_request_to_membuf (fetcher, mirrorlist,
- filename, FALSE, TRUE,
+ filename,
+ OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT,
out_bytes,
OSTREE_MAX_METADATA_SIZE,
cancellable, error);
{
if (!_ostree_fetcher_mirrored_request_to_membuf (pull_data->fetcher,
pull_data->meta_mirrorlist,
- "summary.sig", FALSE, TRUE,
+ "summary.sig", OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT,
&bytes_sig,
OSTREE_MAX_METADATA_SIZE,
cancellable, error))
{
if (!_ostree_fetcher_mirrored_request_to_membuf (pull_data->fetcher,
pull_data->meta_mirrorlist,
- "summary", FALSE, TRUE,
+ "summary", OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT,
&bytes_summary,
OSTREE_MAX_METADATA_SIZE,
cancellable, error))
if (!_ostree_fetcher_mirrored_request_to_membuf (fetcher,
mirrorlist,
commit_filename,
- FALSE, /* don’t add trailing nul */
- TRUE, /* return NULL on ENOENT */
+ OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT,
&commit_bytes,
0, /* no maximum size */
cancellable,